#include <dlfcn.h>
#include <iostream>

typedef void (*plugin_t)();

int main()
{
    auto handleA = dlopen("/home/jerry/study/tests/src/cpp/shared_object_test1/PluginA/PluginA.so", RTLD_LAZY);
    if (!handleA)
    {
        std::cout << "Error: " << dlerror() << std::endl;
    }
    plugin_t a = (plugin_t)dlsym(handleA, "foo");
    a();

    auto handleB = dlopen("/home/jerry/study/tests/src/cpp/shared_object_test1/PluginB/PluginB.so", RTLD_LAZY);
    if (!handleB)
    {
        std::cout << "Error: " << dlerror() << std::endl;
    }

    plugin_t b = (plugin_t)dlsym(handleB, "foo");
    b();

    return 0;
}